package com.ruoyi.web.ydz.service.impl;

import java.util.List;

import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.web.ydz.mapper.DrugDiseaseMapper;
import com.ruoyi.web.ydz.domain.DrugDisease;
import com.ruoyi.web.ydz.service.IDrugDiseaseService;

/**
 * 药品疾病关联Service业务层处理
 * 
 * @author DRX
 * @date 2024-10-17
 */
@Service
public class DrugDiseaseServiceImpl implements IDrugDiseaseService 
{
    @Autowired
    private DrugDiseaseMapper drugDiseaseMapper;

    /**
     * 查询药品疾病关联
     * 
     * @param id 药品疾病关联主键
     * @return 药品疾病关联
     */
    @Override
    public DrugDisease selectDrugDiseaseById(Long id)
    {
        return drugDiseaseMapper.selectDrugDiseaseById(id);
    }

    /**
     * 查询药品疾病关联列表
     * 
     * @param drugDisease 药品疾病关联
     * @return 药品疾病关联
     */
    @Override
    public List<DrugDisease> selectDrugDiseaseList(DrugDisease drugDisease)
    {
        return drugDiseaseMapper.selectDrugDiseaseList(drugDisease);
    }

    /**
     * 新增药品疾病关联
     * 
     * @param drugDisease 药品疾病关联
     * @return 结果
     */
    @Override
    public int insertDrugDisease(DrugDisease drugDisease)
    {
        SysUser user = SecurityUtils.getLoginUser().getUser();
        drugDisease.setCreateBy(user.getUserName());
        drugDisease.setCreateName(user.getNickName());
        drugDisease.setCreateTime(DateUtils.getNowDate());
        return drugDiseaseMapper.insertDrugDisease(drugDisease);
    }

    /**
     * 修改药品疾病关联
     * 
     * @param drugDisease 药品疾病关联
     * @return 结果
     */
    @Override
    public int updateDrugDisease(DrugDisease drugDisease)
    {
        SysUser user = SecurityUtils.getLoginUser().getUser();
        drugDisease.setUpdateBy(user.getUserName());
        drugDisease.setUpdateName(user.getNickName());
        drugDisease.setUpdateTime(DateUtils.getNowDate());
        return drugDiseaseMapper.updateDrugDisease(drugDisease);
    }

    /**
     * 批量删除药品疾病关联
     * 
     * @param ids 需要删除的药品疾病关联主键
     * @return 结果
     */
    @Override
    public int deleteDrugDiseaseByIds(Long[] ids)
    {
        return drugDiseaseMapper.deleteDrugDiseaseByIds(ids);
    }

    /**
     * 删除药品疾病关联信息
     * 
     * @param id 药品疾病关联主键
     * @return 结果
     */
    @Override
    public int deleteDrugDiseaseById(Long id)
    {
        return drugDiseaseMapper.deleteDrugDiseaseById(id);
    }
}
